//package com.example.friendfindertwo.data.helper;
//
//import com.example.friendfindertwo.model.Friend;
//
//import model.Event;
//
//import android.content.ContentValues;
//import android.content.Context;
//import android.database.Cursor;
//import android.database.SQLException;
//import android.database.sqlite.SQLiteDatabase;
//import android.util.Log;
//
//public class FriendDAO extends AbstractDAO{
//	
//	//private SQLiteDatabase database;
//	//private DBHelper dbHelper;
//	long iId;
//	
////	public FriendDAO(Context context){
////		super(context);
////		//this.open();
////	}
//	
////	public void open() throws SQLException{
////		database = dbHelper.getWritableDatabase();
////	}
////	
////	public void close(){
////		dbHelper.close();
////	}
//	
//	public Friend createFriend(String name){
//		ContentValues values = new ContentValues();
//		values.put(FriendTable.COLUMN_NAME, name);
//		long insertId = super.database.insert(FriendTable.TABLE_FRIEND, null, values);
//
//		Cursor cursor = super.database.query(FriendTable.TABLE_FRIEND, null, FriendTable.COLUMN_ID + " = " + insertId, null, null, null, null);
//		cursor.moveToFirst();
//		Friend friend = cursorToFriend(cursor);
//		Log.i("friend", "id: "+insertId);
//		iId = insertId;
//		Log.i("friend", "iId first: "+iId);
//		Log.i("Friend", "create friend "+name);
//		return friend;
//	}
//	
//	private Friend cursorToFriend(Cursor cursor){
//		return new Friend(cursor.getString(0));	
//	}
//	
//	//Cursor cursor = db.query(TABLE_CONTACTS, new String[] { KEY_ID,
//    //        KEY_NAME, KEY_PH_NO }, KEY_ID + "=?",
//    //        new String[] { String.valueOf(id) }, null, null, null, null);
//    //if (cursor != null)
//    //    cursor.moveToFirst();
//	
//	public Friend getFriendById(int id){
//		
//		Log.i("FriendDAO friend by id",""+ id);
//		
////		Cursor cursor = super.database.query(FriendTable.TABLE_FRIEND, new String[]{ FriendTable.COLUMN_ID, FriendTable.COLUMN_NAME },
////										FriendTable.COLUMN_ID + " = ", new String[]{String.valueOf(id)}, null, null, null, null);
//		
//		Cursor cursor = super.database.query(FriendTable.TABLE_FRIEND, new String[]{ FriendTable.COLUMN_ID, FriendTable.COLUMN_NAME },
//				FriendTable.COLUMN_ID + " = "+ id, null, null, null, null);
//		
//		if(cursor != null && cursor.getCount()>1){
//			cursor.moveToFirst();
//			Friend friend = new Friend(cursor.getString(cursor.getColumnIndex(FriendTable.COLUMN_NAME)));
//			Log.i("Success", "Friend " + cursor.getString(cursor.getColumnIndex(FriendTable.COLUMN_NAME)) + " was created");
//			return friend;
//		}else{
//			Log.i("Error", "cursor in getFriendById is null or lower than one");
//		}
//		return null;
//	}
//	
//	public int getId(Friend friend){
//
//		//this.open();
//		
//		Log.i("friend", "output: "+friend.getFriendName());
//		Log.i("friend", "iId: "+iId);
//
//		//Cursor cursor = database.query(FriendTable.TABLE_FRIEND, new String[]{FriendTable.COLUMN_ID},
//		//		FriendTable.COLUMN_NAME + " = ", new String[]{friend.getFriendName()}, null, null, null, null);
//	
//		Cursor cursor = database.query(FriendTable.TABLE_FRIEND, new String[] {FriendTable.COLUMN_ID} , FriendTable.COLUMN_NAME + " like '%fuend%'" /*+ friend.getFriendName()*/, null, null, null, null);
//		//Cursor cursor = database.query(FriendTable.TABLE_FRIEND, new String[] {FriendTable.COLUMN_NAME} , FriendTable.COLUMN_ID + " = " + 21, null, null, null, null);
//		//Cursor cursor = database.query(FriendTable.TABLE_FRIEND, null, null, null, null, null, null);
//		
//		if(cursor != null){
////			cursor.moveToFirst();
////			while(!cursor.isAfterLast()){
////				//Log.i("Success", "Friend " + cursor.getString(1) + " was created");
////				Log.i("Success", "Friend " + cursor.getInt(0) + " was created");
////				cursor.moveToNext();
////			}
//			
//			cursor.moveToFirst();
//			Log.i("Success", "Friend " + cursor.getInt(0) + " was created");
//			//this.close();
//			return cursor.getInt(0);
//			//return 21;
//		}else{
//			Log.i("Error", "cursor in getFriendById is null");
//		}
//		return -1;
//	}
//}
